package gentle.controller;

import gentle.entity.SearchPaymentTotalInfo;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import gentle.service.IPaymentTotalService;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.BufferedOutputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @author py
 * @Date 2018年4月19日23:15:54
 */
@Controller
@RequestMapping("/paymentTotal")
public class PaymentTotalController {
    @Autowired
    IPaymentTotalService paymentTotalService;

    @RequestMapping("/getPaymentTotalReport")
    @ResponseBody
    public List<Map<String, Object>> getPaymentTotalReport(SearchPaymentTotalInfo searchInfo, String reach) {
        return paymentTotalService.getList(searchInfo, reach);
    }

    @RequestMapping("/sumBorrowAmount")
    @ResponseBody
    public HashMap sumBorrowAmount(@RequestParam(required = false) String reach,@RequestParam(required = false) String checkoutMethod,
                                   @RequestParam(required = false) String fieldTc, @RequestParam(required = false) String startTime,
                                   @RequestParam(required = false) String customerStatus,@RequestParam(required = false) String endTime, @RequestParam String abbreviation) {
        return paymentTotalService.sumBorrowAmount(reach, checkoutMethod, fieldTc, startTime, customerStatus, endTime, abbreviation);
    }

    //导出
    @RequestMapping(value = "/paymentTableExport")
    public void paymentTableExport(@Valid SearchPaymentTotalInfo info, HttpServletResponse response) {
        paymentTotalService.paymentTableExport(info,response);
    }

}
